import java.util.Arrays;
import java.util.Scanner;

/**
 * 【程序35】   
 * 题目：输入数组，最大的与第一个元素交换，最小的与最后一个元素交换，输出数组。 
 */
public class test35 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] array = new int[5];
        for (int i = 0; i < 5; i++) {
            System.out.print("请输入数字：");
            array[i] = sc.nextInt();
        }
        int max;
        int min;
        int maxNum = 0;
        int minNum = 0;
        max = array[0];
        min = array[0];
        for (int i = 0; i < 5; i++) {
            if (array[i] <= min){
                min = array[i];
                minNum = i;
            } else if (array[i] > max){
                max = array[i];
                maxNum = i;
            }
        }
        int temp = array[0];
        array[0] = array[maxNum];
        array[maxNum] = temp;

        temp = array[4];
        array[4] = array[minNum];
        array[minNum] = temp;

        System.out.println(Arrays.toString(array));
    }
}
